package cn.gson.crm.test; 


import java.math.BigDecimal;
import java.sql.Time;
import java.util.Date;
import java.util.List;

import javax.xml.crypto.Data;

import org.junit.After;    
import org.junit.Before; 
import org.junit.Test; 
import org.springframework.context.ApplicationContext; 
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.gson.crm.model.pojo.CustomerCare;
import cn.gson.crm.model.pojo.DetailRepair;
import cn.gson.crm.model.pojo.Repair;
import cn.gson.crm.service.LLJ_ComplainService;
import cn.gson.crm.service.LLJ_ConnectorService;
import cn.gson.crm.service.LLJ_CustomerCareService;
import cn.gson.crm.service.LLJ_RepairService;
import cn.gson.crm.service.LLJ_customerService; 


public class LLJ_DemoOne { 
	
    private LLJ_CustomerCareService careService; 
    private LLJ_ConnectorService llj_ConnctorService;   
    private LLJ_ComplainService llj_ComplainService;
    private LLJ_customerService llj_customerService;
    private LLJ_RepairService llj_RepairService;
     
    @Before 
    public void setUp(){ 
    	System.out.println(1);
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext-db.xml");
        System.out.println(2);
        careService=ac.getBean(LLJ_CustomerCareService.class); 
        llj_ConnctorService=ac.getBean(LLJ_ConnectorService.class); 
        llj_ComplainService=ac.getBean(LLJ_ComplainService.class);   
        llj_customerService=ac.getBean(LLJ_customerService.class);     
        llj_RepairService=ac.getBean(LLJ_RepairService.class);     
    } 
    @After 
    public void tearDown(){    
    	careService = null; 
    	llj_ConnctorService=null;
    	llj_ComplainService=null; 
    	llj_customerService=null;   
    	llj_RepairService=null;        
    } 
    
    
   
    @Test
    public void nn(){  
    	//System.out.println("输出："+llj_RepairService.getNewId());
    	System.out.println("输出："+llj_RepairService.findRepair(3L));
    }
      
    @Test
    public void addRepair() {
    	
    	Repair r=new Repair();
    	r.setRepairMoveId("流水工单号4");
    	r.setRepairDatetime(new Date());
    	r.setRepairType("产品销售");
    	r.setCustomerId(new BigDecimal(1));
    	r.setCustomerName("简称1");
    	r.setContId(new BigDecimal(1));
    	r.setContLinkMan("客户联系人");
    	r.setRepairTel("18725678291"); 
    	
    	
    	if(llj_RepairService.addRepairData(r).equals("success")){ 
    		long getId=this.detail();   
        	System.out.println("输出查询出的id值："+getId);
        	System.out.println("维修工单添加成功！");
        	
        	Repair repair=llj_RepairService.findRepair(getId);
        	                             
        	
    		DetailRepair d=new DetailRepair();
    		d.setDrId(getId);
        	d.setDrProduct("维修产品名称4");
        	d.setDrProductSequ("维修产品序列号");
        	d.setDrProductDate(new Date()); 
        	d.setDrProductSale(new Date());
        	d.setDrGuarantee(new BigDecimal(1));
        	d.setDrAttention("注意事项4");
        	d.setDrDeptName("部门名称4"); 
        	d.setDrSpeedProgress("进行中"); 
        	//d.setRepair(repair);
        	d.setDrFee(new BigDecimal(1444.00)); 
        	
        	try {
				if(llj_RepairService.addRepairDetailData(d).equals("success")){
					System.out.println("添加维修工单详情成功！");      
				}else{   
					System.out.println("添加维修工单详情失败！");
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	
    	}else{
    		System.out.println("维修工单添加失败！");
    	}
    }
    @Test 
    public Long detail(){
    	return llj_RepairService.getNewId();   
    }
    
    
    
    @Test
    public void Repair(){
    	try {
			System.out.println("输出:"+llj_RepairService.RePairSearch());
		} catch (Exception e) {
			System.out.println("输出有误！"); 
		}
    }
    
    @Test
    public void UU(){
    	System.out.println("输出："+careService.serchAllCustomer());   
    }
    @Test   
    public void care(){
    	System.out.println("输出："+careService.searchAll());
    }
    @Test
    public void findType(){
    	System.out.println(llj_customerService.findType());  
    }
    @Test
    public void findWay(){
    	System.out.println(llj_customerService.findWay());   
    }
    
    @Test
    public void findAllCustomerMessage() throws Exception{
    	System.out.println("输出内容长度:"+llj_customerService.findAllCustomerMessage().size());
    	System.out.println(llj_customerService.findAllCustomerMessage());     
    	  
    }     
    
    
    @Test
    public void searchByName(){
    	System.out.println("输出客户信息："+llj_ComplainService.searchByName("简称"));    
    }
    @Test
    public void findAllComplain(){
    	System.out.println("输出:"+llj_ComplainService.searchComplain(33L));
    }
    @Test
    public void Time(){
    	System.out.println("输出："+llj_ComplainService.searchTimeDeal());
    }
    @Test         
    public void Type(){
    	System.out.println("输出："+llj_ComplainService.searchType());
    }   
    
    @Test
    public void searchbytheme(){
    	System.out.println("输出查询结果："+llj_ComplainService.searchByTheme("小诗"));  
    }
    @Test
    public void ss(){
    	System.out.println("输出ss----------------"); 
    	System.out.println(llj_ComplainService.searchComplain(5L));  
    	
    }
    @Test 
    public void one(){
    	Long a=2L;  
    	System.out.println("输出："+llj_ConnctorService.getNeedData(23L));         
    	System.out.println("输出："+llj_ConnctorService.getNeedData(23L).getConnectorStateDetails()); 
    	System.out.println("输出数据长度："+llj_ConnctorService.getNeedData(23L).getConnectorStateDetails().size());  
	
      }    
    
    @Test
    public void vv(){
    	System.out.println("-------------------------------------------");
    	System.out.println(careService.getCustomerData(48L));   
    }
    @Test
    public void gg(){
    	CustomerCare cc=new CustomerCare();
    	
    	cc.setCcId(67L);
    	cc.setCcTheme("主题67");
    	cc.setCustomerName("客户67");
    	cc.setCcLinkMan("联系人67");
    	cc.setCcCreationTime(new Date());
    	cc.setCcExecutor("执行人67");
    	cc.setCcContent("内容67");
    	cc.setCcFeedback("客户回馈67");
    	    

    }
    @Test
    public void save(){
    	CustomerCare cc=new CustomerCare();
    	cc.setCcTheme("主题@");
    	cc.setCustomerName("客户@");
    	cc.setCcLinkMan("联系人@"); 
    	cc.setCcCreationTime(new Date());
    	cc.setCcExecutor("执行人@");
    	cc.setCcContent("内容@");
    	cc.setCcFeedback("客户回馈@");    
    	System.out.println("返回值："+careService.addOne_data_CustomerCare(cc));     
    	
    }
    
    
   /* @Test 
    public void two(){
    	System.out.println("-------------------------------------------------");
      	System.out.println("输出：");
      	System.out.println(llj_ConnctorService.findAll_connectorData());   
   }  
    
    @Test 
    public void cc(){
    	System.out.println("-------------------------------------------------");   
      	System.out.println("输出：");
      	System.out.println(careService.find_dataByType_id(1L));  
   }  
    
    @Test 
    public void dd(){
    	System.out.println("-------------------------------------------------");
      	System.out.println("输出：");
      	System.out.println(careService.deleteOneDate(51L));     
   }  
    
   /* @Test 
    public void ee(){
    	System.out.println("-------------------------------------------------");
      	System.out.println("输出：");
      	System.out.println(llj_ConnctorService.findAll_ConnectorSelect());     
   }  */    
    
    
    
    
     
    
} 
